#!/bin/sh
+read _DATE _date_n <<-EOF
+ $(date +"%s %N")
+ EOF
+
. "${_EXEC:-${0%/*}}/cgilite/cgilite.sh"
. "${_EXEC:-${0%/*}}/cgilite/storage.sh"
. "${_EXEC:-${0%/*}}/cgilite/json.sh"
-[ "$_DATE" ] || _DATE="$(date +%s)"
-
debug "$REQUEST_METHOD $REQUEST_URI $SERVER_PROTOCOL $_DATE"
ingest() {
words="$(
for j in $(DB2 "$J" iterate @); do
json_get "$(UNSTRING "$j")" match_phrase_prefix.content
- done 2>/dev/null
+ done 2>/dev/null |tr \\n ' '
)"
debug "Search words: $words"
)"
results="${results% }"
- debug <<-EOF
+ t="$(( $(date +%s%N) - ${_DATE}${_date_n} ))"
+
+ cat <<-EOF
Status: 200 OK\r
X-elastic-product: Elasticsearch\r
Content-Type: application/vnd.elasticsearch+json;compatible-with=8\r
\r
- { "took":0,
+ { "took":$((t / 1000000)),
"timed_out":false,
- "_shards":{"total":1,"successful":1,"skipped":0,"failed":0},
"hits": {
"total":{"value": $(DB2 "$results" count @) ,"relation":"eq"},
"max_score": $(json_get "arr:$results" '[0]._score' 2>/dev/null || printf 0),